from sls_controller.sls_missionsUAVDefault import *
from sls_controller.sls_missionsUAVPlus import *
from sls_controller.sls_missionsUAVDefault import *
from sls_controller.sls_publicResource import PublicResource
from sls_controller.sls_missionsABC import Missions
from sls_controller.sls_missionsUGVDefault import *
import json

class MissionsFactory():
    def __init__(self,publicResource):
        self.publicResource = publicResource
    
    def create_missions_from_type(self,missionsType:str,datasets:dict = None) -> Missions:
        if datasets != None:
            return eval(missionsType)(self.publicResource,datasets)
        else:
            return eval(missionsType)(self.publicResource)
    
    def create_missions_from_json(self,missions:str) -> Missions:
        missionsDict = json.loads(missions)
        return self.create_missions_from_type(missionsDict["missionsType"],missionsDict["datasets"])
    